<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="./CSS/equalizer.css" />
<link type="text/css" href="CSS/smoothness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.mouse.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.slider.min.js"></script>
<script type="text/javascript" src="js/json2.min.js"></script>
<script type="text/javascript">
	
	 
var data='{"stereo":{\
"vol1":{"hz01h":-11,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol2":{"hz01h":-14,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol3":{"hz01h":2,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10}},\
"singletrack":{\
"vol1":{"hz01h":3,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol2":{"hz01h":4,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol3":{"hz01h":5,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol4":{"hz01h":6,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol5":{"hz01h":7,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol6":{"hz01h":7,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10},\
"vol7":{"hz01h":8,"hz02h":2,"hz04h":3,"hz06h":4,"hz01k":5,"hz03k":6,"hz06k":7,"hz12k":8,"hz14k":9,"hz16k":10}}\
 }';
var jo = JSON.parse(data);

var isoldcolor = true;
$(function() {  
	// setup slider
	  var jovalue = selectjson(jo, $("input[type=radio]:checked").val());
	$( ".slider" ).each(function() {
		// read initial values from markup and remove that
		//var value = parseInt( $( this ).text(), 10 );	

			   var value = selectvol(jovalue, $(this).attr("name"));		
		$( this ).empty().slider({
			value:value,
			range: "min",
			min:-14,
			max:14,
			animate: true,
			orientation: "vertical",
			slide: function( event, ui ) {	
               $( "#"+$(this).attr("name")).val(ui.value );
			 //  
			 //   var jovalue = selectjson(jo,$("input[type=radio]:checked").attr("value"));
				//alert($("input[type=radio]:checked").attr("value"));
			//	alert($(this).attr("name")+""+ui.value);
			//setjson(jovalue,$(this).attr("name"),ui.value);
				
				
		},
		
		stop: function( event, ui ) {	
              var  channel =$("input[type=radio]:checked").attr("value");
			 var name =   $(this).attr("id");
		
		   // alert(channel+" "+name+" "+ ui.value);
		 

			   /* $.ajax({		  
                       type: get,		  
                       url: http://xx.xxx.xx.xx/cgi-bin/equalizer_control.cgi,		 
                       data: "channel="+channel+"&"+"operation="+name+"&"+"volume="+ui.value,		  
                        success: function(msg){			 alert( "数据发送成功" + msg );		 
                       }		
              }); */
			   
			    var jovalue = selectjson(jo,$("input[type=radio]:checked").attr("value"));
				
				
			setjson(jovalue,$(this).attr("name"),ui.value);
			data =JSON.stringify(jo);
			
			 
			      
				
				
		 } 
		 
		});
	});
	
	
		$( "table  input[type=text]" ).each(function() {
			
			
		   var audiotxtid = $(this).attr("id");
		  
		   var value = $("#s"+audiotxtid).slider( "value");
			$(this).val(value);
		}); 
		
		$(".equalizerbutton").click(function(){

            
           var name =   $(this).attr("name");
		   var op= name.substring(name.length-1);

		   var audiotxt= name.substring(1,name.length-1);
		  // alert(audiotxt);
		   var sid= name.substring(0,name.length-1);
		   var smin= $("#"+sid).slider( "option","min");
		   var smax= $("#"+sid).slider( "option","max");
		   
		   var value = $("#"+sid).slider( "value");
		 //  var v2 = $("#"+sid).slider( "option", "value")
		 // alert(value+"   "+v2);
		  // var value=$( "#"+audiotxt).val();
		   
		   var jovalue = selectjson(jo,$("input[type=radio]:checked").attr("value"));
		   if(op =="+"){
            // $("#"+sid).slider( "value",value+1);
			 $("#"+sid).slider( "option", "value", (value+1)>smax?smax:(value+1) );
		
			
             }
		 //  alert(value);
		   
		   if(op=="-"){
            //$("#"+sid).slider( "value",v2-1);
			$("#"+sid).slider( "option", "value", (value-1)<smin?smin:(value-1) );
		//	alert(v2-1);
		
			
              }
		    $( "#"+audiotxt).val($("#"+sid).slider( "option", "value"));
			
			
		   var  channel =$("input[type=radio]:checked").attr("value");
			// alert(channel);
			 alert(name+" "+ $( "#"+audiotxt).val());
			   /* $.ajax({		  
                       type: get,		  
                       url: http://xx.xxx.xx.xx/cgi-bin/equalizer_control.cgi,		 
                       data: "channel="+channel+"&"+"operation="+name+"&"+"volume="+$( "#"+audiotxt).val(),		  
                        success: function(msg){			 alert( "数据发送成功" + msg );		 
                       }		
              }); */
		     setjson(jovalue,$("#"+sid).attr("name"),$("#"+sid).slider( "value"));
			 data =JSON.stringify(jo);
			
           

     }); 
		 $(".equalizerbutton").mouseup(function(){
	                   pressed=false;
					//   alert(pressed);
					
		
					if(typeof (intervalProcess)!="undefined" ){
	                  clearInterval(intervalProcess);
					  }
              	    if(typeof (timeoutProcess)!="undefined" ){
                       clearTimeout(timeoutProcess);
					   }

     });
	
	 
	$(".equalizerbutton").mousedown(function(){

       
		      pressed = true;
		
				 
		var $name= $(this).attr("name");
			 
		
			
			 timeoutProcess=setTimeout(function(){
	
	                	if(pressed==true) {
						//alert(pressed);
                        intervalProcess=setInterval(function(){
                            var name =  $name;
		   var op= name.substring(name.length-1);

		   var audiotxt= name.substring(1,name.length-1);
		  // alert(audiotxt);
		   var sid= name.substring(0,name.length-1);
		   var smin= $("#"+sid).slider( "option","min");
		      var smax= $("#"+sid).slider( "option","max");
		   
		   var value = $("#"+sid).slider( "value");
		
		   if(op =="+"){
            // $("#"+sid).slider( "value",value+1);
		 $("#"+sid).slider( "option", "value", (value+1)>smax?smax:(value+1) );
			
             }
	
		   
		   if(op=="-"){
            //$("#"+sid).slider( "value",v2-1);
			$("#"+sid).slider( "option", "value", (value-1)<smin?smin:(value-1) );
	
		
			
              }
		    $( "#"+audiotxt).val($("#"+sid).slider( "option", "value"));
		
                        },150);
						}
                    },250);
					
           

     });
	 
     
    $("table  input[type=radio]").click(function(){
            
            
        
           
         var jovalue = selectjson(jo, $(this).attr("value"));
         var ismute =$("#"+$(this).attr("value")).attr("ismute");
       
         
         if(ismute=="true"){
         	     $("table  input[type=button][name=mute]").val("取消静音");
         	     $("table  input[type=button][name=mute]").css("color","#f00");
         	  
           }
          else{
          	   $("table  input[type=button][name=mute]").val("静音");
          	   $("table  input[type=button][name=mute]").css("color","#000");
          }
         
			   	$( "table  input[type=text]" ).each(function() {
			
			      //  alert($(this).attr("id"));
		         var value = selectvol(jovalue, $(this).attr("id"));
		       //  alert(value);
	
			      $(this).val(value);
		         });
				 
				 $( ".slider" ).each(function() {
				 
				  var value = selectvol(jovalue, $(this).attr("name"));
				  
	                  $(this).slider("option","value",value);
					 
	               });
				 
				 
          
          
         
     }); 
     
      $("table  input[type=button][name=reset]").click(function(){
            
           var jovalue = selectjson(jo,$("input[type=radio]:checked").attr("value"));
        
             resetjson(jovalue,0);
             data =JSON.stringify(jo);
			
		     var  channel =$("input[type=radio]:checked").attr("value");
			 //alert(channel);
			
			   /* $.ajax({		  
                       type: get,		  
                       url: http://xx.xxx.xx.xx/cgi-bin/equalizer_control.cgi,		 
                       data: "channel="+channel+"&"+"operation="+"reset",		  
                        success: function(msg){			 alert( "数据发送成功" + msg );		 
                       }		
              }); */
        
          var rvalue = $("input[type=radio]:checked").attr("value")
           
             var istereo = rvalue.substring(1,2)=="t"?"立体声信号输入":"单声道信号输入";
        
			   	$( "table  input[type=text]" ).each(function() {
			
			      //  alert($(this).attr("id"));
		        // var value = selectvol(jovalue, $(this).attr("id"));
		       //  alert(value);
	
			      $(this).val(0);
		         });
				 
				     $( ".slider" ).each(function() {
				 
				 
				  
	                  $(this).slider( "value",0);
	               });
				 
				 
         alert(istereo+" 音量"+rvalue.substring(rvalue.length-1)+" 均衡设置已复位"); 
          
         
     }); 
     
        $("table  input[type=button][name=mute]").click(function(){
            
           var jovalue = selectjson(jo,$("input[type=radio]:checked").attr("value"));
           var spanid = $("input[type=radio]:checked").attr("value")
           var spancolor =$("#"+spanid).css("color");
             var istereo = spanid.substring(1,2)=="t"?"立体声信号输入":"单声道信号输入";
         // alert($("#"+spanid).attr("ismute"));
        
           if($("#"+spanid).attr("ismute")=="false")
           {
           	 var  channel =$("input[type=radio]:checked").attr("value");
			// alert(channel);
			
			   /* $.ajax({		  
                       type: get,		  
                       url: http://xx.xxx.xx.xx/cgi-bin/equalizer_control.cgi,		 
                       data: "channel="+channel+"&"+"operation="+"mute",		  
                        success: function(msg){			 alert( "数据发送成功" + msg );		 
                       }		
              }); */
            $("#"+spanid).css("color","#f00");
            $("#"+spanid).attr("ismute","true")
            $(this).val("取消静音");
            
            $(this).css("color","#f00");
            alert(istereo+" 音量"+spanid.substring(spanid.length-1)+" 已静音");
            
          }else{
		  
		       	 var  channel =$("input[type=radio]:checked").attr("value");
			 //alert(channel);
			
			   /* $.ajax({		  
                       type: get,		  
                       url: http://xx.xxx.xx.xx/cgi-bin/equalizer_control.cgi,		 
                       data: "channel="+channel+"&"+"operation="+"unmute",		  
                        success: function(msg){			 alert( "数据发送成功" + msg );		 
                       }		
              }); */
          	    
          	   $("#"+spanid).css("color","#000");
          	   $("#"+spanid).attr("ismute","false")
          	     $(this).val("静音");
          	   $(this).css("color","#000");
          	    alert(istereo+" 音量"+spanid.substring(spanid.length-1)+" 取消静音！");
          	}
        
				 
				  
				   
				   
          
          
         
     });
	 
	 

	
});


function selectjson(data, rv) 
{


   switch (rv)
   {
   case "st1":
       return data.stereo.vol1;
   case "st2":
       return data.stereo.vol2;
   case "st3":
       return data.stereo.vol3;
   case "si1":
       return data.singletrack.vol1;
   case "si2":
       return data.singletrack.vol2;
    case "si3":
       return data.singletrack.vol3;
	case "si4":
       return data.singletrack.vol4;
	case "si5":
       return data.singletrack.vol5;
	case "si6":
       return data.singletrack.vol6;
	case "si7":
       return data.singletrack.vol7;

    default:
       return ;
}

};

function setjson(data, sn,value) 
{

   
   switch (sn)
   {
   case "hz01h":
       data.hz01h=value;
	   break;
   case "hz02h":
       data.hz02h=value;
	   break;
   case "hz04h":
       data.hz04h=value;
	   break;
   case "hz06h":
       data.hz06h=value;
	    break;
    case "hz01k":
       data.hz01k=value;
	    break;
	case "hz03k":
       data.hz03k=value;
	    break;
	case "hz06k":
       data.hz06k=value;
	    break;
	case "hz12k":
       data.hz12k=value;
	    break;
	case "hz14k":
       data.hz14k=value;
	    break;
	case "hz16k":
       data.hz16k=value;
	    break;
    default:
       return ;
}

};

function resetjson(data,value) 
{

   
   for(var p in data){
   
   	data[p] = value;
   	 
   
   	
   	
  }

};

function selectvol(data, tid) 
{


   switch (tid)
   {
   case "hz01h":
       return data.hz01h;
   case "hz02h":
       return data.hz02h;
   case "hz04h":
       return data.hz04h;
   case "hz06h":
       return data.hz06h;
    case "hz01k":
       return data.hz01k;
	case "hz03k":
       return data.hz03k;
	case "hz06k":
       return data.hz06k;
	case "hz12k":
       return data.hz12k;
	case "hz14k":
       return data.hz14k;
	case "hz16k":
       return data.hz16k;
    default:
       return 999;
}

}; 
</script>
</head>

<body>
<p id="text_area0">均衡设置</p>
<div id="equalizer"> 
<table id="first" cellpadding="2px">
    <caption>输出声道信号</caption>
    <tr>
        <th><input name="singleselection" type="radio" checked=true, value="st1" /><span id="st1" ismute="false">主输出</span></th>
        <th><input name="singleselection" type="radio" value="st2" /><span id="st2" ismute="false">辅助输出1</span></th>
		<th><input name="singleselection" type="radio" value="st3" /><span id="st3" ismute="false">辅助输出2</span></th>
    </tr>
</table>
<table id="second" cellpadding="2px">
    <caption>单声道信号输入</caption>
    <tr>
        <th><input name="singleselection" type="radio" value="si1" /><span id="si1" ismute="false">音量1</span></th>
        <th><input name="singleselection" type="radio" value="si2" /><span id="si2" ismute="false">音量2</span></th>
        <th><input name="singleselection" type="radio" value="si3" /><span id="si3" ismute="false">音量3</span></th>
        <th><input name="singleselection" type="radio" value="si4" /><span id="si4" ismute="false">音量4</span></th>
        <th><input name="singleselection" type="radio" value="si5" /><span id="si5" ismute="false">音量5</span></th>
        <th><input name="singleselection" type="radio" value="si6" /><span id="si6" ismute="false">音量6</span></th>
		<th><input name="singleselection" type="radio" value="si7" /><span id="si7" ismute="false">音量7</span></th>
    </tr>
</table>
<table id="third" cellpadding="4px">
    <tr>
        <td><input type="text" id="hz01h" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz02h" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz04h" onfocus="this.blur()"/></td>
        <td><input type="text" id="hz06h" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz01k" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz03k" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz06k" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz12k" onfocus="this.blur()" /></td>
        <td><input type="text" id="hz14k" onfocus="this.blur()"/></td>
        <td><input type="text" id="hz16k" onfocus="this.blur()" /></td>
    </tr>
    <tr>
        <td><input type="button" class="equalizerbutton"  name="shz01h+"  value="+" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz02h+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz04h+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz06h+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz01k+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz03k+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz06k+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz12k+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz14k+"  value="+"/></td>
        <td><input type="button" class="equalizerbutton"  name="shz16k+"  value="+"/></td>
        <td>+14dB</td>
    </tr>
	<tr>
        <td><div class="slider" id="shz01h" name="hz01h">-14</div></td>
        <td><div class="slider" id="shz02h" name="hz02h">2</div></td>
        <td><div class="slider" id="shz04h" name="hz04h">3</div></td>
        <td><div class="slider" id="shz06h" name="hz06h">4</div></td>
        <td><div class="slider" id="shz01k" name="hz01k">5</div></td>
        <td><div class="slider" id="shz03k" name="hz03k">6</div></td>
        <td><div class="slider" id="shz06k" name="hz06k">7</div></td>
        <td><div class="slider" id="shz12k" name="hz12k">8</div></td>
        <td><div class="slider" id="shz14k" name="hz14k">9</div></td>
        <td><div class="slider" id="shz16k" name="hz16k">10</div></td>
        <td>
            <div class="index"></div>
            <p>0dB</p>
            <div class="index"></div>
        </td>
    </tr>
	<tr>
        <td><input type="button" class="equalizerbutton"  name="shz01h-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz02h-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz04h-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz06h-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz01k-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz03k-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz06k-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz12k-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz14k-" value="-" /></td>
        <td><input type="button" class="equalizerbutton"  name="shz16k-" value="-" /></td>
        <td>-14dB</td>
    </tr>
    <tr>
        <td>高音</td>
        <td>中音</td>
        <td>低音</td>
        <td>600Hz</td>
        <td>1KHz</td>
        <td>3KHz</td>
        <td>6KHz</td>
        <td>12KHz</td>
        <td>14KHz</td>
        <td>16KHz</td>
    </tr>
</table>
<table id="four">
    <tr>
        <td><input name="reset" type="button" value="复位均衡" /></td>
        <td><input name="mute" type="button" value="静音" /></td>
        <td><div style="background-color:#00557F"><a href="audio_control.html" target="showframe">&lt;&lt;&nbsp;返回</a></div></td>
    </tr>
</table>
</div>
</body>
</html>
